package com.kjlink.widget.oa.enums;

import com.kjlink.widget.oa.model.OAProject;
import com.kjlink.widget.oa.model.OaDepartment;
import com.kjlink.widget.oa.model.OaUser;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;

import java.util.List;

/**
 * 描述:
 * 要同步带 oa 的一些 url
 *
 * @author Vic.xu
 * @since 2025-09-01 9:23
 */
public enum OaApiUrlEnum implements OaApiUrlInterface {

    USER_SYNC("用户", "/KjlinkPmsBackend/oa/sync/user",
            HttpMethod.GET,
            new ParameterizedTypeReference<List<OaUser>>() {
            }),

    DEPT_SYNC("部门", "/KjlinkPmsBackend/oa/sync/dept",
            HttpMethod.GET,
            new ParameterizedTypeReference<List<OaDepartment>>() {
            }),

    PROJECT_SYNC("项目", "/KjlinkPmsBackend/oa/sync/s/project",
            HttpMethod.GET,
            new ParameterizedTypeReference<List<OAProject>>() {
            }),

    BO_PROJECT_SYNC("商机项目", "/KjlinkPmsBackend/oa/sync/p/project",
            HttpMethod.GET,
            new ParameterizedTypeReference<List<OAProject>>() {
            }
    );

    String name;

    String url;

    HttpMethod method;

    //绑定当前枚举对应的返回类型（支持泛型，如List<Project>）
    ParameterizedTypeReference<?> responseType;

    OaApiUrlEnum(String name, String url, HttpMethod method, ParameterizedTypeReference<?> responseType) {
        this.name = name;
        this.url = url;
        this.method = method;
        this.responseType = responseType;
    }

    public String getName() {
        return name;
    }

    @Override
    public String getUrl() {
        return url;
    }

    @Override
    public HttpMethod getMethod() {
        return method;
    }

    @Override
    public ParameterizedTypeReference<?> getResponseType() {
        return responseType;
    }
}
